package it.intecs.pisa.smarcos.base;

import android.app.DownloadManager;
import android.content.Context;
import android.net.Uri;
import android.os.Environment;
import android.util.Log;



public class Downloads {

	private static final String TAG = Downloads.class.getSimpleName();
	private Context context;

	public Downloads(Context con) {

		context = con;

	}

	public void download(String url, String description, String title){

		Log.d(TAG,"download");

		DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
		request.setDescription(description);
		request.setTitle(title);

		request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "name-of-the-file.ext");

		DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
		manager.enqueue(request);
	}
}